# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=eww
pkgver=0.2.0_git20220215
_gitrev=fb0e57a0149904e76fb33807a2804d4af82350de
pkgrel=0
pkgdesc="ElKowars wacky widgets"
url="https://elkowar.github.io/eww/"
arch="aarch64 x86_64"  # blocked by rustup
license="MIT"
# XXX: eww requires rust nightly, so we cannot build it with our rustc.
#  Don't move this aport out of the testing repo until it can be built with
#  our rust!
makedepends="
	rustup
	gtk+3.0-dev
	gtk-layer-shell-dev
	"
subpackages="$pkgname-dbg"
source="https://github.com/elkowar/eww/archive/$_gitrev/eww-$_gitrev.tar.gz"
builddir="$srcdir/$pkgname-$_gitrev"

export CARGO_HOME="$srcdir/.cargo"
export RUSTUP_HOME="$srcdir/.rustup"
export PATH="$CARGO_HOME/bin:$PATH"

export RUSTFLAGS="-Ctarget-feature=-crt-static"
# Reduce binary size (7.1 -> 4.1 MiB for 0.2.0_git20220215).
export CARGO_PROFILE_RELEASE_CODEGEN_UNITS=1
export CARGO_PROFILE_RELEASE_LTO="true"
export CARGO_PROFILE_RELEASE_OPT_LEVEL="s"
export CARGO_PROFILE_RELEASE_PANIC="abort"

prepare() {
	default_prepare

	rustup-init \
		--target "$CARCH-unknown-linux-musl" \
		--default-toolchain nightly \
		--profile minimal \
		--no-modify-path \
		-y

	cargo fetch --locked
}

build() {
	cargo build --frozen --release --no-default-features --features=wayland
}

check() {
	cargo test --frozen
}

package() {
	install -D -m755 target/release/eww -t "$pkgdir"/usr/bin/
}

sha512sums="
728120fd1c0c797a8f61982dda9e12c92575b6a10ca4c16e4307a752bbaf0263197af4d43b76ed9213f2a6b6d56da7dbf7535ccb1f3548efa4d0610e3884262f  eww-fb0e57a0149904e76fb33807a2804d4af82350de.tar.gz
"
